/**
* 封装本地存储操作模块
*/
export const setItem = (key, value) => {

  // 将数组、对象类型的数据转换为 JSON 格式字符串进行存储
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  window.localStorage.setItem(key, value)

}
export const getItem = key => {
  try {
    var str = localStorage.getItem(key)
    return JSON.parse(str)
  } catch (err) {
    return localStorage.getItem(key)
  }
}
export const removeItem = key => {
  window.localStorage.removeItem(key)
}